<template>
  <div>
    <zbTable
      ref="tableRef"
      :api-fun="get_other_balance_list"
      @action="action"
    />

    <!-- 新增弹窗 -->
    <add
      v-if="showAdd"
      v-model:visible="showAdd"
      :order_sn="editData.order_sn"
      @done="done"
    />
  </div>
</template>
<script setup>
  import { ref, unref, reactive } from 'vue';
  import { message, Modal } from 'ant-design-vue';
  import { actionFn } from '@/utils/action.js';
  import { daochuFn } from '@/utils/daochu.js';
  import { PlusOutlined, UploadOutlined } from '@ant-design/icons-vue';
  import { useRouter } from 'vue-router';
  import zbTable from './components/purchasePurchaseIndex.vue';
  import add from './components/add.vue';
  import { get_other_balance_list } from '@/api/order/other_balance';
  // 是否显示编辑弹窗
  const tableRef = ref(null);
  const router = useRouter();
  const { push } = useRouter();
  const editData = ref({});
  const actionData = ref({});
  const showAdd = ref(false);

  const action = (data) => {
    console.log('data--22222--', data);
    if (data.action_data.type == 'add') {
      editData.value = data.row_data;
      actionData.value.url = data.row_data.url;
      showAdd.value = true;
    } else if (data.action_data.type == 'edit') {
      editData.value = data.row_data;
      actionData.value.url = data.action_data.url;
      showAdd.value = true;
    } else if (data.action_data.type == 'extract') {
      editData.value = data.row_data;
      actionData.value.url = data.action_data.url;
      Modal.confirm({
        title: '提示',
        content: '确定删除?',
        maskClosable: false,
        onOk: () => {
          done({ id: [data.row_data.id] });
        }
      });
    }
  };

  const done = (form) => {
    actionFn(actionData.value, form, reloadTable);
  };
  const reloadTable = () => {
    showAdd.value = false;
    tableRef.value.reload();
  };
</script>
